package com.learn.educourseboot.controller;

import com.alibaba.fastjson.JSON;
import com.learn.eduapi.entity.Course;
import com.learn.eduapi.entity.CourseActivity;
import com.learn.educourseboot.config.RabbitMQConfig;
import com.learn.educourseboot.service.CourseActivityService;
import com.learn.educourseboot.service.CourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @BelongsProject: edu-learn
 * @Author:
 * @CreateTime: 2020-10-16 16:17
 * @Description:
 */
@Slf4j
@Api
@RestController
@RequestMapping("course-activity")
public class CourseActivityController {

    @Autowired
    private CourseActivityService courseActivityService;

    @ApiOperation("更新课程活动库存")
    @PutMapping("/{activityId}")
    public ResponseEntity<CourseActivity> reduceActivityStock(@PathVariable("activityId") Long activityId){
        CourseActivity courseActivity = courseActivityService.reduceActivityStock(activityId);
        log.info("更新课程库存完成{}",courseActivity);
        return ResponseEntity.ok(courseActivity);
    }
}
